﻿using System;
using System.Collections.Generic;
using System.IO;

namespace _02.ConcatenateTextFiles
{
    class ConcatenateTextFiles
    {
        static void CreateFileWithNumberRange(int start, int end, string fileName)
        {
            if (start > end)
            {
                var temp = start;
                start = end;
                end = temp;
            }

            StreamWriter streamWriter = new StreamWriter(fileName);
            using (streamWriter)
            {
                for (int i = start; i <= end; i++)
                {
                    streamWriter.WriteLine(i);
                }
            }
        }

        static object FileContent(string fileName)
        {
            StreamReader file = new StreamReader(fileName);
            using (file)
            {
                return file.ReadToEnd();
            }
        }

        static void Main()
        {
            CreateFileWithNumberRange(1, 20, "TextFile1.txt");
            CreateFileWithNumberRange(40, 60, "TextFile2.txt");
            using (StreamWriter streamWriter = new StreamWriter("TextFile1+2.txt"))
            {
                streamWriter.Write(FileContent("TextFile1.txt"));
                streamWriter.Write(FileContent("TextFile2.txt"));
            }
        }
    }
}
